class Solution(object):
    def maxDepth(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
        def BFS(root):
            queue = []
            if root == None:
                return 0
            queue.append(root)
            depth = 0
            while len(queue) > 0:
                num = len(queue)
                for i in range(num):
                    node = queue.pop(0)
                    if node.left is not None:
                        queue.append(node.left)
                    if node.right is not None:
                        queue.append(node.right)
                depth += 1
            return depth
        return BFS(root)
